/*
 * Socket.h
 *
 *  PEREIRA, FERNANDO ROQUE
 *  91610
 *
 *  Se encapsulara la funcionalidad de los sockets, provista por la API del
 *  sistema operativo
 */

#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#include <sys/types.h>	//	setsockopt(); Para reusar el address!

#include <iostream>
#include <cstring>

#ifndef SOCKET_H_
#define SOCKET_H_

class Socket {
	protected:
		int sockFd;
		struct sockaddr_in	sockAddr;

	public:
		Socket();
		Socket(int socketFd) : sockFd(socketFd) {};
		virtual ~Socket();

		void setAddr_in(unsigned int numPuerto, const char* ip);
		virtual int sendMessage(const void* message, unsigned int tamMessage);
		virtual int sendMessage(int sockFd, const void* message,
				unsigned int tamMessage);
		virtual int receiveMessage(void* buffer, size_t len);
		virtual int receiveMessage(int sockFd, void* buffer, size_t len);

		int cerrarSocket();
		int shutDownSocket();

		struct sockaddr_in getSockAddr();
		unsigned int getSockPort();
		unsigned int getPeerPort();
};


#endif
